package com.bnz.controller;

import com.bnz.entity.Classes;
import com.bnz.service.ClassesService;
import com.bnz.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//@Controller // 注入到spring容器中
//@ResponseBody // 将java对象转为json格式
@RestController // 上面两个的整合
@RequestMapping("classes")
public class ClassesController {

    // 引入ClassesService
    @Autowired
    private ClassesService classesService;

    // 查询classes表里的全部数据
    @RequestMapping("list")
    public R findAll(){
        List<Classes> all = classesService.findAll();
        return R.ok().data("list",all); // "list"是前端传的参数
    }

}

